<?php

use yii\helpers\Url;

?>
<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">子路由</label>
        <div class="layui-input-inline">
            <input type="text" name="route_name" lay-verify="required" placeholder="请输入子菜单名" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">路由</label>
        <div class="layui-input-inline">
            <input type="text" name="route" lay-verify="required" placeholder="路由" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-inline">
            <input type="text" name="sort" lay-verify="required" placeholder="请输入整数" autocomplete="off"
                   class="layui-input" value="10">
            <input type="hidden" name="<?=Yii::$app->request->csrfParam?>" value="<?=Yii::$app->request->csrfToken?>">
            <input type="hidden" name="menu_id" value="<?=$menuId?>">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <input type="checkbox" checked value="1" lay-filter="moduleStatus" name="is_show" lay-skin="switch" lay-text="显示|隐藏">
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="module-submit" id="module-submit" value="确认">
    </div>
</div>

<?php $this->beginBlock('footer') ?>
<script>
    layui.config({
        base: '<?=Url::base()?>/resources/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$
            , form = layui.form;
        form.on('switch(moduleStatus)',function (obj) {
            console.log(obj)
            let is_show = obj.value;
            if(is_show==1){
                obj.elem.defaultValue = 2;
            }else {
                obj.elem.defaultValue = 1;
            }
        })
    })
</script>
<?php $this->endBlock() ?>

